package com.heima.wemedia.controller.v1;

import com.heima.common.dtos.ResponseResult;
import com.heima.wemedia.dto.WmNewsDto;
import com.heima.wemedia.dto.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    /**
     * 文章列表查询
     */
    @PostMapping("/list")
    public ResponseResult findNews(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findNews(dto);
    }


    /**
     * 文章内容发布
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submit(dto);
    }


    /**
     * 文章内容回显
     * @return
     */
    @GetMapping("/one/{newsId}")
    public ResponseResult dataEcho(@PathVariable("newsId") Integer newsId){
        return wmNewsService.dataBack(newsId);
    }
}
